﻿using QuestionInvestig.Business;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace QuestionInvestig.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            Requestentity request = new Requestentity();
            request.title = "测试试卷AAAAAA";
            request.content = "测试";
            QuestionInsertService.quesInsert(request);
            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";
            var a = "";
            return View();
        }

        /// <summary>
        /// 登陆方法
        /// </summary>
        /// <param name="name"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public string LogOn(string name, string password)
        {
            String[] names = { "admin", "张三", "李四" };
            var msg = string.Empty;
            if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(password))
            {
                if (names.Contains(name.Trim()) && password == "123")
                {
                    return "true";//指定要跳的地方
                }
                else
                {
                    msg = "账户或密码不正确！";

                }
            }
            else
            {
                msg = "账户或密码不能为空！";
            }
            return msg;
        }


        public Response Insertdata(Requestentity model)
        {
            //var a = request;
            //Requestentity request = new Requestentity();
            //request.title = title;
            // request.content = content;
            Response r =QuestionInsertService.quesInsert(model);
            return r;
        }
    }
}